package LuMin.file.Text;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * @author lumin
 * @date 2022/05/09 21:02
 **/
public class text3 {
    static String source = "";
    static String dest = "";

    public static void main(String[] args) throws IOException{
        File srcFile = new File(source);
        if(srcFile.isDirectory()){
            System.out.println("源不是根目录");
            return;
        }

        File destFile = new File(dest);
        if(destFile.isDirectory()){
            System.out.println("目标已经存在");
            return;
        }


        traversal(srcFile,destFile);
    }

    private static void traversal(File dir, File destFile) throws IOException {
        File[] files = dir.listFiles();
        if(files == null){
            return;
        }
        for (File file:files) {
            if(file.isDirectory()){
                String path1 = file.getCanonicalPath();
                String relative = path1.substring(source.length());
                String path2 = dest + relative;
                File file2 = new File(path2);
                file2.mkdirs();
                traversal(file,destFile);
            }else if(file.isFile()){

            }
        }
    }
}